<?php
// +---------------------------------------------------------------------+
// | laravel    | [ Only you can't imagine,nothing you can't achieve]  |
// +---------------------------------------------------------------------+
// | Author     | kingcode <158117261@qq.com>                         |
// +---------------------------------------------------------------------+
// +---------------------------------------------------------------------+

namespace App\Tools;
use AstroTool\SweTest;
use AstroTool\planetName;
use App\Models\Api\CorpusTwo;
use App\Models\Api\Astrocalendar as AstrocalendarModel;
/**
 * 星相日历
 */
class Astrocalendar
{
    public $modelAstrocalendar;
    public function __construct(){
        $model = new AstrocalendarModel();
        $this->modelAstrocalendar = $model;
    }

    //一月内相位数据
    public function astroCalendar($year,$month,$tz=8)
    {
        $tz*=3600;
        $PlanetName = new planetName();
        $this->planetNameObject = $PlanetName;
        $planetChinese = $this->planetNameObject::$planetChinese;
        $planetOneChinese = $this->planetNameObject::$planetOneChinese;
        $signChinese2 = $this->planetNameObject::$signChinese;
        $signChinese = array("白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座", "水瓶座", "双鱼座");
        $SignNamesSimple = array("羊", "牛", "双", "蟹", "狮", "处", "秤", "蝎", "射", "摩", "瓶", "鱼");
        $allow_degree_cn = [
            '0' => '合',
            '30' => '十二分',
            '36' => '十分',
            '45' => '八分',
            '60' => '六合',
            '72' => '五分',
            '90' => '刑',
            '120' => '拱',
            '135' => '补八分',
            '144' => '补五分',
            '150' => '梅花',
            '180' => '冲'
        ];

        $start_time = mktime(0, 0, 0, $month, 1, $year);

        $start_time_yue = $start_time;

        //$lastdaytime = mktime(0, 0, 0, $month+1 , 1, $year);

        $step = date('t', $start_time) + 3;
        //$step = 360;
        $start_time -= 86400;
        
        $get_sql_where['month'] = intval($month);
        $get_sql_where['year'] = intval($year);
        $astrocalendarList = $this->modelAstrocalendar->where($get_sql_where)->get();

        $plan_in_plan = array();
        $plan_in_signs = array();
        $plan_in_speed = array();
        $ri_shi_solecl = array();
        $yue_shi_lunecl = array();
      
      $corpusTwoWhere['chartType'] = 5;
      //$corpusTwoWhere['type'] = ['in',[5,6]];
      $Corpus = new CorpusTwo();
      $corpusConstellationColumn = $Corpus->where($corpusTwoWhere)->whereIn('type',[5,6])->get(['id','oneself','other','degree','keywords','content']);
      //dd($corpusConstellationColumn);
        //1相位 2星座 4逆反 6新月 9满月  13空亡开始 14空亡结束
        // 15日食半影开始 17日食本影开始 18日食本影结束 19日食半影结束
        //20月食半影开始 21月食半影结束 22月食本影开始 25月食本影结束
        if (!$astrocalendarList->isEmpty()) {
            foreach ($astrocalendarList as $ekuysf => $valuesff) {
                if ($valuesff['type'] == 1) {
                    //相位
                    $valuep_cha = $valuesff['allow'] - $valuesff['longitude'];
                    if ($valuep_cha > 180) {
                        $valuep_cha = 360 - $valuep_cha;
                    }
                    $plan_in_plan_info['planet_code1'] = $valuesff['planet_code1'];
                    $plan_in_plan_info['planet_code2'] = $valuesff['planet_code2'];
                    $plan_in_plan_info['timestamp'] = $valuesff['time_start'];
                    $plan_in_plan_info['allow'] = $valuesff['allow'];
                    $plan_in_plan_info['allow_cha'] = $valuep_cha;
                    $plan_in_plan_info['longitude'] = $valuesff['longitude'];
                    $plan_in_plan[] = $plan_in_plan_info;
                } elseif ($valuesff['type'] == 2) {
                    //星座
                    $plan_in_sign_info['planet_code'] = $valuesff['planet_code1'];
                    $plan_in_sign_info['sign'] = $valuesff['planet_code2'];
                    $plan_in_sign_info['timestamp'] = $valuesff['time_start'];
                    $plan_in_sign_info['longitude'] = $valuesff['longitude'];
                    $plan_in_signs[] = $plan_in_sign_info;
                } elseif ($valuesff['type'] == 3) {

                } elseif ($valuesff['type'] == 4) {
                    //逆反
                    $plan_in_speed_info['planet_code'] = $valuesff['planet_code1'];
                    $plan_in_speed_info['sign'] = $valuesff['planet_code2'];
                    $plan_in_speed_info['timestamp'] = $valuesff['time_start'];
                    $plan_in_speed_info['longitude'] = $valuesff['longitude'];
                    $plan_in_speed_info['in_type'] = $valuesff['expand'];
                    $plan_in_speed[] = $plan_in_speed_info;
                } elseif (in_array($valuesff['type'],[15,19])) {
                    //日食
                    $strat_end_shi[15]='开始';
                    $strat_end_shi[19]='结束';
                    $valuesff['time_start']+=$tz;
                    $day_time = strtotime(date('Y-m-d', $valuesff['time_start']));
                    empty($ri_shi_solecl[$day_time]) && $ri_shi_solecl[$day_time] = array();
                    $ri_shi_solecl_start['type'] = $valuesff['type'];
                    $ri_shi_solecl_start['title_short'] = '日食';
                    $ri_shi_solecl_start['title'] = $signChinese[$valuesff['planet_code2']].'日食'.$strat_end_shi[$valuesff['type']];
                    $ri_shi_solecl_start['date'] = date('Y-m-d H:i', $valuesff['time_start']);
                    $ri_shi_solecl_start['time'] = date('H:i', $valuesff['time_start']);
                    $ri_shi_solecl[$day_time][] = $ri_shi_solecl_start;
                }elseif (in_array($valuesff['type'],[20,25])) {
                    //月食
                    $strat_end_shi[20]='开始';
                    $strat_end_shi[25]='结束';
                    $valuesff['time_start']+=$tz;
                    $day_time = strtotime(date('Y-m-d', $valuesff['time_start']));
                    empty($yue_shi_lunecl[$day_time]) && $yue_shi_lunecl[$day_time] = array();
                    $valuesff['time_start']+=$tz;
                    $day_time = strtotime(date('Y-m-d', $valuesff['time_start']));
                    empty($yue_shi_lunecl[$day_time]) && $yue_shi_lunecl[$day_time] = array();
                    $yue_shi_lunecl_start['title_short'] = $signChinese[$valuesff['planet_code2']].'月食'.$strat_end_shi[$valuesff['type']];
                    $yue_shi_lunecl_start['type'] = $valuesff['type'];
                    $yue_shi_lunecl_start['timestamp'] = $valuesff['time_start'];
                    $yue_shi_lunecl_start['date'] = date('Y-m-d H:i', $valuesff['time_start']);
                    $yue_shi_lunecl_start['time'] = date('H:i', $valuesff['time_start']);
                    $yue_shi_lunecl[$day_time][] = $yue_shi_lunecl_start;
                }
            }

            $step = 0;
        }
        $SweTest = new SweTest();
        $this->SweTest = $SweTest;
        
        if ($step > 0) {
            $start_time_b=date('d.m.Y', $start_time);
            $planet = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
            $arr = [
                'b' => $start_time_b,
                'ut' => '0:00:0',
                'p' => '1',
                'd' => '0',
                'n' => $step,
                // 'house' => '9.2,45.46666666666667,K',
                's' => '1440m',
                'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                'g' => ',',
                'head',
                'roundsec',
            ];
            //$planet = [0,3];
            $post_data_list = array();
            $plan_in_plan_new = array();

            $phase=[0, 60, 90, 120, 180];
            for ($i = 0; $i < count($planet); $i++) {
                for ($j = $i + 1; $j < count($planet); $j++) {
                    //$planet_phase[] = ['p' => $planet[$i], 'd' => $planet[$j], 'phase' => [0, 60, 90, 120, 180]];
                    if ((in_array($planet[$i], [7, 8, 9]) and $planet[$j] == 1) || (in_array($planet[$j], [7, 8, 9]) and $planet[$i] == 1)) {
                        continue;
                    }
                    $arr['p'] = $planet[$i];
                    $arr['d'] = $planet[$j];

                    $phase_li=array();
                    //$this->getTimeData($arr, $phase, $step, '1440m',$phase_li);

                    $phase_li = $this->getDayData($arr, [0, 60, 90, 120, 180]);
                       
                    if (!empty($phase_li) and count($phase_li)>0) {

                        $plan_in_plan_new = array_merge($plan_in_plan_new, $phase_li);
                    }
                }
            }
            $plan_in_plan = array_merge($plan_in_plan, $plan_in_plan_new);
            foreach ($plan_in_plan_new as $keusner => $nsdhvar) {
                $post_data_info = array();
                $post_data_info['planet_code1'] = $nsdhvar['planet_code1'];
                $post_data_info['planet_code2'] = $nsdhvar['planet_code2'];
                $post_data_info['time_start'] = $nsdhvar['timestamp'];
                $post_data_info['allow'] = $nsdhvar['allow'];
                $post_data_info['longitude'] = $nsdhvar['longitude'];
                $post_data_info['type'] = 1;
                $post_data_info['month'] = intval($month);
                $post_data_info['year'] = intval($year);
                $post_data_list[] = $post_data_info;
            }
            ///星座落入计算
            $arr2 = [
                'b' => $start_time_b,
                'ut' => '0:00:0',
                'p' => implode('', $planet),
                'n' => $step,
                // 'house' => '9.2,45.46666666666667,K',
                's' => '1440m',
                'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                'g' => ',',
                'head',
                'roundsec'
            ];

            $plan_in_signs_new = $this->getSignDayData($arr2);
           
            $plan_in_signs = array_merge($plan_in_signs, $plan_in_signs_new);

            foreach ($plan_in_signs_new as $keusn => $nsdhvar) {
                $post_data_info = array();
                $post_data_info['planet_code1'] = $nsdhvar['planet_code'];
                $post_data_info['planet_code2'] = $nsdhvar['sign'];
                $post_data_info['time_start'] = $nsdhvar['timestamp'];
                $post_data_info['longitude'] = $nsdhvar['longitude'];
                $post_data_info['type'] = 2;
                $post_data_info['month'] = intval($month);
                $post_data_info['year'] = intval($year);
                $post_data_list[] = $post_data_info;
            }
            $arr3 = [
                'b' => $start_time_b,
                'ut' => '0:00:0',
                'p' => implode('', $planet),
                'n' => $step,
                // 'house' => '9.2,45.46666666666667,K',
                's' => '1440m',
                'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                'g' => ',',
                'head',
                'roundsec'
            ];
            //计算顺逆
            $plan_in_speed_new = $this->getSpeedDayData($arr3);
            $plan_in_speed = array_merge($plan_in_speed, $plan_in_speed_new);
            foreach ($plan_in_speed_new as $keusn => $nsdhvar) {
                $post_data_info = array();
                $post_data_info['planet_code1'] = $nsdhvar['planet_code'];
                $post_data_info['planet_code2'] = $nsdhvar['sign'];
                $post_data_info['time_start'] = $nsdhvar['timestamp'];
                $post_data_info['longitude'] = $nsdhvar['longitude'];
                $post_data_info['expand'] = $nsdhvar['in_type'];
                $post_data_info['type'] = 4;
                $post_data_info['month'] = intval($month);
                $post_data_info['year'] = intval($year);
                $post_data_list[] = $post_data_info;
            }

            //日食
            $arr4 = [
                'b' => $start_time_b,
                'solecl' => '',
                'head'];

            $solecl_json = $this->SweTest->SweTest($arr4);
            $new_solecl_date = preg_split("/\s+/", trim($solecl_json[1]));
            $new_solecl_time = preg_split("/\s+/", trim($solecl_json[2]));

            if (preg_match("/^\d{1,2}\.\d{1,2}\.\d{4}$/", $new_solecl_date[1])) {
                $ri_name = $new_solecl_date[0];
                $bb = strtotime($new_solecl_date[1] . ' ' . $new_solecl_time[0]);
                $dd = strtotime($new_solecl_date[1] . ' ' . $new_solecl_time[3]);
            } else {
                $ri_name = $new_solecl_date[0] . ' ' . $new_solecl_date[1];
                $bb = strtotime($new_solecl_date[2] . ' ' . $new_solecl_time[0]);
                $dd = strtotime($new_solecl_date[2] . ' ' . $new_solecl_time[3]);
            }

            if (intval($month) == date("m", $bb)) {
                $arr4_ri = [
                    'b' => date('d.m.Y', $bb),
                    'ut' => date('H:i:s', $bb),
                    'p' => "0",
                    'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                    'g' => ',',
                    'head',
                    'roundsec'];

                $solecl_sign_json = $this->SweTest->SweTest($arr4_ri);
                $solecl_sign_json_array = explode(',', $solecl_sign_json[0]);
                $solecl_ri_sign_defug = $this->SweTest->crunch(trim($solecl_sign_json_array[2], ' '));
                $post_data_info = array();
                $post_data_info['planet_code1'] = '0';
                $post_data_info['type'] = 15;
                $post_data_info['time_start'] = $bb;
                $post_data_info['longitude'] = $solecl_ri_sign_defug;
                $post_data_info['planet_code2'] = intval($post_data_info['longitude'] / 30);
                $post_data_info['expand'] = $ri_name;
                $post_data_info['month'] = intval($month);
                $post_data_info['year'] = intval($year);
                $post_data_list[] = $post_data_info;

                $ri_shi_solecl_start = $post_data_info;
                $ri_shi_solecl_start['timestamp'] = $post_data_info['time_start'] + $tz;
                $ri_shi_solecl_start['title_short'] = '日食';
                $ri_shi_solecl_start['title'] = $signChinese[$post_data_info['planet_code2']].'日食开始';
                $ri_shi_solecl_start['date'] = date('Y-m-d H:i', $ri_shi_solecl_start['timestamp']);
                $ri_shi_solecl_start['time'] = date('H:i', $ri_shi_solecl_start['timestamp']);

                $day_time = strtotime(date('Y-m-d', $ri_shi_solecl_start['timestamp']));
                empty($ri_shi_solecl[$day_time]) && $ri_shi_solecl[$day_time] = array();
                $ri_shi_solecl[$day_time][] = $ri_shi_solecl_start;


                $post_data_info['type'] = 19;
                $post_data_info['time_start'] = $dd;
                $post_data_list[] = $post_data_info;
                $ri_shi_solecl_end = $ri_shi_solecl_start;
                $ri_shi_solecl_end['type'] = $post_data_info['type'];
                $ri_shi_solecl_end['title'] = $signChinese[$post_data_info['planet_code2']].'日食结束';
                $ri_shi_solecl_end['timestamp'] = $post_data_info['time_start']+ $tz;
                $ri_shi_solecl_end['time'] = date('H:i', $ri_shi_solecl_end['timestamp'] );
                $ri_shi_solecl_end['date'] = date('Y-m-d H:i', $ri_shi_solecl_end['timestamp'] );

                $day_time = strtotime(date('Y-m-d', $ri_shi_solecl_end['timestamp']));
                empty($ri_shi_solecl[$day_time]) && $ri_shi_solecl[$day_time] = array();
                $ri_shi_solecl[$day_time][] = $ri_shi_solecl_end;

            }

            //月食
            $arr5 = [
                'b' => $start_time_b,
                'lunecl' => '',
                'head'];
            $lunecl_json = $this->SweTest->SweTest($arr5);

            $lunecl_date = preg_split("/\s+/", trim($lunecl_json[1]));
            $lunecl_datetime = preg_split("/\s+/", trim($lunecl_json[2]));
            $yue_shi_name = $lunecl_date[0] . ' ' . $lunecl_date[1] . ' ' . $lunecl_date[2];
            $bb = strtotime($lunecl_date[3] . ' ' . $lunecl_datetime[0]);
            $dd = strtotime($lunecl_date[3] . ' ' . $lunecl_datetime[5]);

            if (intval($month) == date("m", $bb)) {
                $arr5_yue = [
                    'b' => date('d.m.Y', $bb),
                    'ut' => date('H:i:s', $bb),
                    'p' => "1",
                    'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                    'g' => ',',
                    'head',
                    'roundsec'];

                $lunecl_sign_json = $this->SweTest->SweTest($arr5_yue);
                $lunecl_sign_json_array = explode(',', $lunecl_sign_json[0]);
                $lunecl_yue_sign_defug = $this->SweTest->crunch(trim($lunecl_sign_json_array[2], ' '));
                $post_data_info = array();
                $post_data_info['planet_code1'] = '1';
                $post_data_info['type'] = 20;
                $post_data_info['time_start'] = $bb;
                $post_data_info['longitude'] = $lunecl_yue_sign_defug;
                $post_data_info['planet_code2'] = intval($post_data_info['longitude'] / 30);
                $post_data_info['expand'] = $yue_shi_name;
                $post_data_info['month'] = intval($month);
                $post_data_info['year'] = intval($year);
                $post_data_list[] = $post_data_info;

                $yue_shi_lunecl_start = $post_data_info;
                $yue_shi_lunecl_start['timestamp'] = $post_data_info['time_start'] + $tz;
                $yue_shi_lunecl_start['title_short'] = '月食';
                $yue_shi_lunecl_start['title'] = $signChinese[$post_data_info['planet_code2']].'月食开始';
                $yue_shi_lunecl_start['date'] = date('Y-m-d H:i', $yue_shi_lunecl_start['timestamp']);
                $yue_shi_lunecl_start['time'] = date('H:i', $yue_shi_lunecl_start['timestamp']);

                $day_time = strtotime(date('Y-m-d', $yue_shi_lunecl_start['timestamp']));
                empty($yue_shi_lunecl[$day_time]) && $yue_shi_lunecl[$day_time] = array();
                $yue_shi_lunecl[$day_time][] = $yue_shi_lunecl_start;

                $post_data_info['type'] = 25;
                $post_data_info['time_start'] = $dd ;
                $post_data_list[] = $post_data_info;
                $yue_shi_lunecl_end = $yue_shi_lunecl_start;
                $yue_shi_lunecl_end['timestamp'] = $post_data_info['time_start'] + $tz;
                $yue_shi_lunecl_end['time'] = date('H:i', $yue_shi_lunecl_end['timestamp']);
                $yue_shi_lunecl_end['type'] = $post_data_info['type'];
                $yue_shi_lunecl_end['title'] = $signChinese[$post_data_info['planet_code2']].'月食结束';
                $yue_shi_lunecl_end['date'] = date('Y-m-d H:i', $yue_shi_lunecl_end['timestamp']);

                $day_time = strtotime(date('Y-m-d', $yue_shi_lunecl_end['timestamp']));
                empty($yue_shi_lunecl[$day_time]) && $yue_shi_lunecl[$day_time] = array();
                $yue_shi_lunecl[$day_time][] = $yue_shi_lunecl_end;

            }
            $this->modelAstrocalendar->save($post_data_list);
        }

        // 相位  新月 满月

        foreach ($plan_in_plan as $keydate => $valuedate) {

            empty($planet_all_data[strtotime(date('Y-m-d', $valuedate['timestamp']))]) && $planet_all_data[strtotime(date('Y-m-d', $valuedate['timestamp']))] = array();
            $valuedate['timestamp'] += $tz;
            $valuedate['type'] = 1;
            $valuedate['time'] = date('H:i', $valuedate['timestamp']);
            $valuedate['title_short'] = $planetOneChinese[$valuedate['planet_code1']] . $allow_degree_cn[$valuedate['allow']] . $planetOneChinese[$valuedate['planet_code2']];
            $valuedate['title'] = $planetChinese[$valuedate['planet_code1']] .$allow_degree_cn[$valuedate['allow']]. $planetChinese[$valuedate['planet_code2']];
            
            //新增 关键词
            
            $valuedate['keywords'] ='';
            $valuedate['content'] ='';

            foreach ($corpusConstellationColumn as $keycr=>$valuecr){
                if((($planetChinese[$valuedate['planet_code1']]==$valuecr['oneself'] and $planetChinese[$valuedate['planet_code2']]==$valuecr['other']) or ($planetChinese[$valuedate['planet_code1']]==$valuecr['other'] and $planetChinese[$valuedate['planet_code2']]==$valuecr['oneself'])) and $valuecr['degree']==$valuedate['allow']){
                    $valuedate['keywords'] =$valuecr['keywords'];
                    $valuedate['content'] =$valuecr['content'];
                    break;
                }
            }
            //
            $valuedate['date'] = date('Y-m-d H:i', $valuedate['timestamp']);

            $planet_all_data[strtotime(date('Y-m-d', $valuedate['timestamp']))][] = $valuedate;

            if ($valuedate['planet_code1'] == 0 and $valuedate['planet_code2'] == 1) {
                if ($valuedate['allow'] == 0) {
                    $valuedate['type'] = 6;
                    $valuedate['title_short'] = '新月';

                    $arry_yue = [
                        'b' => date('d.m.Y', ($valuedate['timestamp']-$tz)),
                        'ut' => date('H:i:s', ($valuedate['timestamp']-$tz)),
                        'p' => "1",
                        'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                        'g' => ',',
                        'head',
                        'roundsec'];
                    $xinyue_sign_json = $this->SweTest->SweTest($arry_yue);
                    $xinyue_sign_json_array = explode(',', $xinyue_sign_json[0]);
                    $xinyue_sign_defug = $this->SweTest->crunch(trim($xinyue_sign_json_array[2], ' '));
                    $xinyue_sign = intval($xinyue_sign_defug / 30);
                    $valuedate['title'] = $signChinese[$xinyue_sign].'新月';

                    $planet_all_data[strtotime(date('Y-m-d', $valuedate['timestamp']))][] = $valuedate;
                }
                if ($valuedate['allow'] == 180) {
                    $valuedate['type'] = 9;
                    $valuedate['title_short'] = '满月';

                    $arry_yue = [
                        'b' => date('d.m.Y', ($valuedate['timestamp']-$tz)),
                        'ut' => date('H:i:s', ($valuedate['timestamp']-$tz)),
                        'p' => "1",
                        'f' => 'PTls',  //名字 时间 度数经度 速度 宫位
                        'g' => ',',
                        'head',
                        'roundsec'];
                    $manyue_sign_json = $this->SweTest->SweTest($arry_yue);
                    $manyue_sign_json_array = explode(',', $manyue_sign_json[0]);
                    $manyue_sign_defug = $this->SweTest->crunch(trim($manyue_sign_json_array[2], ' '));
                    $manyue_sign = intval($manyue_sign_defug / 30);
                    $valuedate['title'] = $signChinese[$manyue_sign].'满月';

                    $planet_all_data[strtotime(date('Y-m-d', $valuedate['timestamp']))][] = $valuedate;
                }
            }
        }


        $yue_kong_wang = array();
        //顺逆

        $shun_ni_lit = array();
        foreach ($plan_in_speed as $kegl => $vjks) {

            $type_str = '顺';
            if ($vjks['in_type'] == -1) {
                $type_str = '逆';
            }
            $vjks['timestamp'] += $tz;
            $vjks['date'] = date('Y-m-d H:i', ($vjks['timestamp']));
            $vjks['type'] = 4;
            $vjks['time'] = date('H:i', $vjks['timestamp']);
            $vjks['end_date'] = "";
            $vjks['title_short'] = $planetOneChinese[$vjks['planet_code']] . $type_str;
            $vjks['title'] = $planetChinese[$vjks['planet_code']].'在'.$signChinese[$vjks['sign']] . $type_str.'行';
            $shun_ni_lit[strtotime(date('Y-m-d', $vjks['timestamp']))][] = $vjks;
        }


        $plan_sign_in_sign = array();
        foreach ($plan_in_signs as $keups => $voleps) {
            $plan_sign_in_sign[$voleps['planet_code']][] = $voleps;
        }

        //星座
        foreach ($plan_in_signs as $keups => $voleps) {
            empty($plan_in_signs_two[strtotime(date('Y-m-d', $voleps['timestamp']))]) && $plan_in_signs_two[strtotime(date('Y-m-d', $voleps['timestamp']))] = array();
            $voleps['timestamp'] += $tz;
            $voleps['type'] = 2;
            $voleps['time'] = date('H:i', $voleps['timestamp']);
            $voleps['date'] = date('Y-m-d H:i:s', $voleps['timestamp']);

            $voleps['end_date'] = "";
            
            $voleps['title_short'] = $planetOneChinese[$voleps['planet_code']] . $SignNamesSimple[$voleps['sign']];
            $voleps['title'] = $planetChinese[$voleps['planet_code']] .'进入'. $signChinese[$voleps['sign']];
            $voleps['keywords'] = '';
            $voleps['content'] = '';
           // print_r($voleps);die;
           //新增关键词
              foreach ($corpusConstellationColumn as $keycr=>$valuecr){
                if($signChinese2[$voleps['sign']]==$valuecr['other'] and $planetChinese[$voleps['planet_code']]==$valuecr['oneself']){
                    $voleps['content'] = $valuecr['content'];
                    $voleps['keywords'] = $valuecr['keywords'];
                    break;
                }
            }
            //
            $plan_in_signs_two[strtotime(date('Y-m-d', $voleps['timestamp']))][] = $voleps;

            //空亡
            if ($voleps['planet_code'] == 1) {
                $max_kong = 0;
                $yuekongkaodate = array();
                foreach ($plan_in_plan as $keydate => $valuedate) {
                    if ($valuedate['planet_code1'] == 1 or $valuedate['planet_code2'] == 1) {
                        $valuedate['timestamp'] += $tz;
                        if ($valuedate['timestamp'] < $voleps['timestamp'] and $max_kong < $valuedate['timestamp']) {

                            $max_kong = $valuedate['timestamp'];
                            $yuekongkaodate = $valuedate;
                            $yuekongkaodate['type'] = 13;
                            $yuekongkaodate['time'] = date('H:i', $valuedate['timestamp']);
                            $yuekongkaodate['end_date'] = "";
                            $yuekongkaodate['title_short'] = '月空始';
                            $yuekongkaodate['title'] = '月亮空亡开始';
                            $yuekongkaodate['date'] = date('Y-m-d H:i', $yuekongkaodate['timestamp']);
                        }
                    }
                }
                if (!empty($yuekongkaodate)) {
                    $yue_kong_wang[strtotime(date('Y-m-d', $yuekongkaodate['timestamp']))][] = $yuekongkaodate;
                }
                $yuekongjiedate = $voleps;
                $yuekongjiedate['type'] = 14;
                $yuekongjiedate['title_short'] = '月空终';
                $yuekongjiedate['title'] = '月亮空亡结束';
                $yue_kong_wang[strtotime(date('Y-m-d', $voleps['timestamp']))][] = $yuekongjiedate;
            }

        }
        $data_pland = array();
        $day_count = date('t', $start_time_yue);


        for ($i = 0; $i < $day_count; $i++) {

            $day_day = intval(date('d', $start_time_yue + $i * 86400));
            empty($data_pland[$day_day]) && $data_pland[$day_day] = array();
            //相位
            if (!empty($planet_all_data[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $planet_all_data[$start_time_yue + $i * 86400]);
            }
            //星座
            if (!empty($plan_in_signs_two[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $plan_in_signs_two[$start_time_yue + $i * 86400]);
            }
            //顺逆
            if (!empty($shun_ni_lit[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $shun_ni_lit[$start_time_yue + $i * 86400]);
            }
            //空亡
            if (!empty($yue_kong_wang[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $yue_kong_wang[$start_time_yue + $i * 86400]);
            }
            //月食
            if (!empty($yue_shi_lunecl[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $yue_shi_lunecl[$start_time_yue + $i * 86400]);
            }
            //日食
            if (!empty($ri_shi_solecl[$start_time_yue + $i * 86400])) {
                $data_pland[$day_day] = array_merge($data_pland[$day_day], $ri_shi_solecl[$start_time_yue + $i * 86400]);
            }
        }
        return $data_pland;
    }

    public function getTimeData($arr, $phase, $n, $s,&$result)
    {
        $arr['n'] = $n;
        $arr['s'] = $s;

        $planet_json = $this->SweTest->SweTest($arr);

        $planet_json_count = count($planet_json);

        foreach ($phase as $keyp => $valuep) {
            foreach ($planet_json as $key => $value) {
                if ($key >= ($planet_json_count - 1)) {
                    break 1;
                }
                $new_lineInfo = explode(',', $value);
                $new_defug = trim($new_lineInfo[2], ' ');
                $next_lineInfo = explode(',', $planet_json[$key + 1]);
                $next_defug = trim($next_lineInfo[2], ' ');

                $valuep_cha = $valuep - $new_defug;
                if ($valuep_cha > 180) {
                    $valuep_cha = 360 - $valuep_cha;
                }
                $xia_bu = $this->interval_value($new_defug, $valuep, $next_defug);

                if ($xia_bu) {
                    $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                    if (!empty($newMoon)) {
                        $newMoon_time = strtotime($newMoon);
                        $arr['b'] = date('d.m.Y', $newMoon_time);
                        $arr['ut'] = date('H:i:s', $newMoon_time);
                    }
                    $phase_xia = [$valuep];
                    switch ($s) {
                        case '1440m':
                            $this->getTimeData($arr, $phase_xia, "25", "60m",$result);
                            break;
                        case '60m':
                            $this->getTimeData($arr, $phase_xia, "61", "1m",$result);
                            break;
                        case '1m':
                            $this->getTimeData($arr, $phase_xia, "61", "1s",$result);
                            break;
                        case '1s':


                          $result[] = ['planet_code1' => $arr['p'], 'planet_code2' => $arr['d'], 'timestamp' => $newMoon_time, 'allow_cha' => $valuep_cha, 'allow' => $valuep, 'longitude' => $new_defug];

                            break;
                    }

                }
            }
        }
    }
    //天----相位
    public function getDayData($arr, $phase)
    {

        $planet_json = $this->SweTest->SweTest($arr);

        $planet_json_count = count($planet_json);
        $plants = array();
        foreach ($phase as $keyp => $valuep) {
            foreach ($planet_json as $key => $value) {
                if ($key >= ($planet_json_count - 1)) {
                    break 1;
                }
                $new_lineInfo = explode(',', $value);
                $new_defug = trim($new_lineInfo[2], ' ');

                $next_lineInfo = explode(',', $planet_json[$key + 1]);
                $next_defug = trim($next_lineInfo[2], ' ');

                $valuep_cha = $valuep - $new_defug;
                if ($valuep_cha > 180) {
                    $valuep_cha = 360 - $valuep_cha;
                }

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }

                $xia_bu = $this->interval_value($new_defug, $valuep, $next_defug);

                if ($xia_bu) {
                    if (abs($valuep_cha) < 0.02) {
                        $plants[] = ['planet_code1' => $arr['p'], 'planet_code2' => $arr['d'], 'timestamp' => $newMoon_time, 'allow_cha' => $valuep_cha, 'allow' => $valuep, 'longitude' => $new_defug];
                    } else {
                        $phase_xia = [$valuep];
                        $plants[] = $this->getHoursData($arr, $phase_xia);
                    }
                }

            }
        }

        if (!empty($plants)) {
            return $plants;
        }
    }

    //小时----相位
    public function getHoursData($arr, $phase)
    {
        $arr['n'] = '25';
        $arr['s'] = '60m';
        $planet_json = $this->SweTest->SweTest($arr);
        $planet_json_count = count($planet_json);
        foreach ($phase as $keyp => $valuep) {
            foreach ($planet_json as $key => $value) {
                if ($key >= ($planet_json_count - 1)) {
                    break 1;
                }
                $dian = false;
                $new_lineInfo = explode(',', $value);
                $new_defug = trim($new_lineInfo[2], ' ');

                $next_lineInfo = explode(',', $planet_json[$key + 1]);
                $next_defug = trim($next_lineInfo[2], ' ');

                $valuep_cha = $valuep - $new_defug;
                if ($valuep_cha > 180) {
                    $valuep_cha = 360 - $valuep_cha;
                }

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }

                $xia_bu = $this->interval_value($new_defug, $valuep, $next_defug);
                if ($xia_bu) {
                    if (abs($valuep_cha) < 0.02) {
                        return ['planet_code1' => $arr['p'], 'planet_code2' => $arr['d'], 'timestamp' => $newMoon_time, 'allow_cha' => $valuep_cha, 'allow' => $valuep, 'longitude' => $new_defug];
                    } else {
                        $phase_xia = [$valuep];
                        return $this->getMinutesData($arr, $phase_xia);
                    }
                }
            }
        }
    }

    //分----相位
    public function getMinutesData($arr, $phase)
    {
        $arr['n'] = '61';
        $arr['s'] = '1m';
        $planet_json = $this->SweTest->SweTest($arr);

        $planet_json_count = count($planet_json);

        foreach ($phase as $keyp => $valuep) {
            foreach ($planet_json as $key => $value) {
                if ($key >= ($planet_json_count - 1)) {
                    break 1;
                }
                $dian = false;
                $new_lineInfo = explode(',', $value);
                $new_defug = trim($new_lineInfo[2], ' ');

                $next_lineInfo = explode(',', $planet_json[$key + 1]);
                $next_defug = trim($next_lineInfo[2], ' ');

                $valuep_cha = $valuep - $new_defug;
                if ($valuep_cha > 180) {
                    $valuep_cha = 360 - $valuep_cha;
                }

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }

                $xia_bu = $this->interval_value($new_defug, $valuep, $next_defug);

                if ($xia_bu) {
                    if (abs($valuep_cha) < 0.02) {
                        return ['planet_code1' => $arr['p'], 'planet_code2' => $arr['d'], 'timestamp' => $newMoon_time, 'allow_cha' => $valuep_cha, 'allow' => $valuep, 'longitude' => $new_defug];
                    } else {
                        $phase_xia = [$valuep];
                        return $this->getSecondsData($arr, $phase_xia);
                    }
                }
            }
        }
    }

    //秒----相位
    public function getSecondsData($arr, $phase)
    {
        $arr['n'] = '61';
        $arr['s'] = '1s';
        $planet_json = $this->SweTest->SweTest($arr);

        $planet_json_count = count($planet_json);

        foreach ($phase as $keyp => $valuep) {
            foreach ($planet_json as $key => $value) {
                if ($key >= ($planet_json_count - 1)) {
                    break 1;
                }
                $dian = false;
                $new_lineInfo = explode(',', $value);
                $new_defug = trim($new_lineInfo[2], ' ');
                $next_lineInfo = explode(',', $planet_json[$key + 1]);
                $next_defug = trim($next_lineInfo[2], ' ');
                $valuep_cha = abs(abs($valuep) - abs($new_defug));
                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }
                $xia_bu = $this->interval_value($new_defug, $valuep, $next_defug);
                if ($xia_bu) {
                    if (abs($valuep_cha) < 0.05) {
                        return ['planet_code1' => $arr['p'], 'planet_code2' => $arr['d'], 'timestamp' => $newMoon_time, 'allow_cha' => $valuep_cha, 'allow' => $valuep, 'longitude' => $new_defug];
                    }
                }
            }
        }
    }

    //计算是否在相位内
    public function interval_value($shang, $value, $xia)
    {
        $isset_t = false;
        if ($shang > 0 and $xia < 0) {
            if (($shang - $xia) > 180) {
                if ($shang < $value and abs($xia) < $value) {
                    $isset_t = true;
                }
            } else {
                if ($shang > $value and abs($xia) > $value) {
                    $isset_t = true;
                }
            }
        } else if ($shang < 0 and $xia > 0) {
            //前负后正
            if (($xia - $shang) > 180) {
                if (abs($shang) < $value and $xia < $value) {
                    $isset_t = true;
                }
            } else {
                if (abs($shang) > $value and $xia > $value) {
                    $isset_t = true;
                }
            }
        } else {
            $shang_zheng = abs($shang);
            $xia_zheng = abs($xia);
            if (($value >= $shang_zheng and $value < $xia_zheng) or ($value <= $shang_zheng and $value > $xia_zheng)) {
                $isset_t = true;
            }
        }
        return $isset_t;
    }

    //计算星座  天
    public function getSignDayData($arr)
    {
        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_defug = $this->SweTest->crunch(trim($next_lineInfo[2], ' '));
                $newsign_num = intval($new_defug / 30);

                if ($new_defug > $next_defug and abs($new_defug - $next_defug) > 180) {
                    $next_defug = $next_defug + 360;
                }

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }
                if ($next_defug >= ($newsign_num + 1) * 30) {
                    $arr_xia = $arr;

                    $planetEnglish = $this->planetNameObject::$planetEnglish;
                    $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                    $data_array[] = $this->getSignHoursData($arr_xia);

                }
            }
        }
        return $data_array;
    }

    //计算星座  小时
    public function getSignHoursData($arr)
    {
        $arr['n'] = '25';
        $arr['s'] = '60m';

        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_defug = $this->SweTest->crunch(trim($next_lineInfo[2], ' '));
                $newsign_num = intval($new_defug / 30);

                if ($new_defug > $next_defug and abs($new_defug - $next_defug) > 180) {
                    $next_defug = $next_defug + 360;
                }

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }
                if ($next_defug >= ($newsign_num + 1) * 30) {
                    $arr_xia = $arr;

                    $planetEnglish = $this->planetNameObject::$planetEnglish;
                    $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                    return $this->getSignMinutesData($arr_xia);
                }

            }
        }

    }

    //计算星座  分
    public
    function getSignMinutesData($arr)
    {
        $arr['n'] = '61';
        $arr['s'] = '1m';

        $planet_json = $this->SweTest->SweTest($arr);

        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_defug = $this->SweTest->crunch(trim($next_lineInfo[2], ' '));
                $newsign_num = intval($new_defug / 30);
                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if ($new_defug > $next_defug and abs($new_defug - $next_defug) > 180) {
                    $next_defug = $next_defug + 360;
                }
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);

                    if ($next_defug >= ($newsign_num + 1) * 30) {
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                        return $this->getSignSecondsData($arr_xia);
                    }
                }
            }
        }
    }

//计算星座  秒
    public
    function getSignSecondsData($arr)
    {
        $arr['n'] = '61';
        $arr['s'] = '1s';

        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_defug = $this->SweTest->crunch(trim($next_lineInfo[2], ' '));
                $next_defug_old = $next_defug;
                $newsign_num = intval($new_defug / 30);
                $next_Moon = str_replace(' UT', '', $next_lineInfo[1]);
                if ($new_defug > $next_defug and abs($new_defug - $next_defug) > 180) {
                    $next_defug = $next_defug + 360;
                }
                if (!empty($next_Moon)) {
                    $nextMoon_time = strtotime($next_Moon);
                    if ($next_defug >= ($newsign_num + 1) * 30) {
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        return ['planet_english' => str_replace(' ', '', $next_lineInfo[0]), 'planet_code' => (string)array_search(str_replace(' ', '', $next_lineInfo[0]), $planetEnglish), 'sign' => intval($next_defug_old / 30), 'timestamp' => $nextMoon_time, 'longitude' => $next_defug_old];
                    }
                }
            }
        }
    }


//计算顺逆  天
    public
    function getSpeedDayData($arr)
    {
        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_speed = trim($new_lineInfo[3], ' ');
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_speed = trim($next_lineInfo[3], ' ');
                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                    if ($new_speed >= 0 && $next_speed <= 0) {
                        //逆行
                        $new_lineInfo['in_type'] = -1;
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                        $data_array[] = $this->getSpeedHoursData($arr_xia);
                    }
                    if ($new_speed <= 0 && $next_speed >= 0) {
                        //顺行
                        $new_lineInfo['in_type'] = 1;
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                        $data_array[] = $this->getSpeedHoursData($arr_xia);
                    }
                }
            }
        }
        return $data_array;
    }

//计算顺逆  小时
    public
    function getSpeedHoursData($arr)
    {
        $arr['n'] = '25';
        $arr['s'] = '60m';
        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_speed = trim($new_lineInfo[3], ' ');
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_speed = trim($next_lineInfo[3], ' ');
                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                    if ($new_speed >= 0 && $next_speed <= 0) {
                        //逆行
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                        return $this->getSpeedMinutesData($arr_xia);
                    }
                    if ($new_speed <= 0 && $next_speed >= 0) {
                        //顺行
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        $arr_xia['p'] = (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish);
                        return $this->getSpeedMinutesData($arr_xia);
                    }
                }
            }
        }

    }

//计算顺逆  分
    public
    function getSpeedMinutesData($arr)
    {
        $arr['n'] = '61';
        $arr['s'] = '1m';
        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_speed = trim($new_lineInfo[3], ' ');
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $newsign_num = intval($new_defug / 30);
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_speed = trim($next_lineInfo[3], ' ');
                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                    if ($new_speed >= 0 && $next_speed <= 0) {
                        //逆行
                        $arr_xia = $arr;
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        return ['planet_english' => str_replace(' ', '', $new_lineInfo[0]),
                            'planet_code' => (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish),
                            'sign' => $newsign_num, 'timestamp' => $newMoon_time, 'longitude' => $new_defug, 'in_type' => -1];
                    }
                    if ($new_speed <= 0 && $next_speed >= 0) {
                        //顺行
                        $planetEnglish = $this->planetNameObject::$planetEnglish;
                        return ['planet_english' => str_replace(' ', '', $new_lineInfo[0]),
                            'planet_code' => (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish),
                            'sign' => $newsign_num, 'timestamp' => $newMoon_time, 'longitude' => $new_defug, 'in_type' => 1];
                    }
                }
            }
        }
    }

//计算顺逆  秒
    public
    function getSpeedSecondsData($arr)
    {
        $arr_xia['n'] = '61';
        $arr_xia['s'] = '1s';

        $planet_json = $this->SweTest->SweTest($arr);
        $step = $arr['n'] - 1;
        $planet_count = count(str_split($arr['p']));
        $data_array = array();
        for ($i = 0; $i < $step; $i++) {
            for ($j = 0; $j < $planet_count; $j++) {
                $value = $planet_json[$i * $planet_count + $j];
                $new_lineInfo = explode(',', $value);
                $new_defug = $this->SweTest->crunch(trim($new_lineInfo[2], ' '));
                $next_lineInfo = explode(',', $planet_json[($i + 1) * $planet_count + $j]);
                $next_defug = $this->SweTest->crunch(trim($next_lineInfo[2], ' '));
                $newsign_num = intval($new_defug / 30);

                $newMoon = str_replace(' UT', '', $new_lineInfo[1]);
                if (!empty($newMoon)) {
                    $newMoon_time = strtotime($newMoon);
                    $arr['b'] = date('d.m.Y', $newMoon_time);
                    $arr['ut'] = date('H:i:s', $newMoon_time);
                }
                if ($next_defug >= ($newsign_num + 1) * 30) {
                    $planetEnglish = $this->planetNameObject::$planetEnglish;
                    return ['planet_english' => str_replace(' ', '', $new_lineInfo[0]), 'planet_code' => (string)array_search(str_replace(' ', '', $new_lineInfo[0]), $planetEnglish), 'sign' => $newsign_num + 1, 'timestamp' => $newMoon_time, 'longitude' => $new_defug];
                }
            }
        }
    }


}
